//
//  BKNewUserInfoITTACell.m
//  bestkeep
//
//  Created by windCould on 17/1/4.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKNewUserInfoITTACell.h"
#import "BKMyCommon.h"

@interface BKNewUserInfoITTACell ()

@property (nonatomic,strong)UIImageView * headImgV;
@property (nonatomic,strong)UILabel * headTitleLab;
@property (nonatomic,strong)UILabel * subTitleLab;
@property (nonatomic,strong)UIImageView * arrowImgV;
@property (nonatomic,strong)UIView * bottomLineView;

@end


@implementation BKNewUserInfoITTACell

+(instancetype)cellWithTableview:(UITableView *)tableview
{
    BKNewUserInfoITTACell * cell = [tableview dequeueReusableCellWithIdentifier:BKNewUserInfoITTACellId];
    if (cell == nil) {
        
        cell = [[BKNewUserInfoITTACell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BKNewUserInfoITTACellId];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(void)fillData:(id)data
{
    CellModel * model = data;
    _headImgV.image = [UIImage imageNamed:model.image];
    _headTitleLab.text = model.title;
    _subTitleLab.text = model.subTitle;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setUpViews];
    }
    
    return self;
}

-(void)setUpViews
{
    
    _headImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
    [self.contentView addSubview:_headImgV];
    
    _headTitleLab =[[UILabel alloc]initWithFrame:CGRectZero];
    _headTitleLab.font = [UIFont systemFontOfSize:15];
    _headTitleLab.textColor = BK_MY_COLOR_07;
    [self.contentView addSubview:_headTitleLab];
    
    _subTitleLab = [[UILabel alloc]initWithFrame:CGRectZero];
    _subTitleLab.font = [UIFont systemFontOfSize:14];
    _subTitleLab.textAlignment = NSTextAlignmentRight;
    _subTitleLab.textColor = BK_MY_COLOR_04;
    [self.contentView addSubview:_subTitleLab];
    
    _arrowImgV = [[UIImageView alloc]initWithFrame:CGRectZero];\
    _arrowImgV.image = [UIImage imageNamed:@"BK_My_LeftArrow"];
    _arrowImgV.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:_arrowImgV];
    
    _bottomLineView = [[UIView alloc]initWithFrame:CGRectZero];
    _bottomLineView.backgroundColor = RGBCOLOR(218, 218, 218, 1);
    [self.contentView addSubview:_bottomLineView];
    
    
    [self layoutViews];
}

-(void)layoutViews{
   
        
    CGFloat    diatance = ApplicationBackGauge;
    [_headImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(diatance);
        make.size.mas_equalTo(CGSizeMake(22, 22));
        
    }];
    
    [_headTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.left.mas_equalTo(_headImgV.mas_right).offset(8);
        make.height.mas_equalTo(@(20));
        make.width.mas_equalTo(@(100));
    }];
    
    [_subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.right.mas_equalTo(_arrowImgV.mas_left).offset(-6);
        make.left.mas_equalTo(_headTitleLab.mas_right).offset(10);
        make.height.mas_equalTo(@(20));
    }];
    
    [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(@(0.5));
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
    }];
    
    [_arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge + 2);
        make.size.mas_equalTo(CGSizeMake(15,15));
    }];
    
}

@end
